package com.hnxxxy.service.impl;

import com.hnxxxy.mapper.AssociationAdministrationMapper;
import com.hnxxxy.mapper.AuditMapper;
import com.hnxxxy.pojo.Activity;
import com.hnxxxy.pojo.Association;
import com.hnxxxy.pojo.User;
import com.hnxxxy.pojo.User_ass;
import com.hnxxxy.service.AuditService;
import com.hnxxxy.system.aop.myLog.MyLog;
import com.hnxxxy.utils.Communal;
import net.sf.json.JSONObject;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AuditServiceImpl implements AuditService {
    private static final Logger log= LogManager.getLogger(AuditServiceImpl.class);

    @Autowired
    AuditMapper auditMapper;

    @Autowired
    AssociationAdministrationMapper associationAdministrationMapper;

    @Autowired
    Communal communal;

    /**
     * 查询申请社团所有审核信息
     *
     * @return  申请社团所有审核信息
     */
    public String queryAppAssAudInfo(int page,int limit) {
        log.debug("执行AuditServiceImpl的queryAppAssAudInfo");
        return communal.runterListJson(page,limit,auditMapper.queryAppAssAudInfo());
    }

    /**
     * 审核操作
     *
     * @param association 审核信息
     * @return 操作成功或失败的信息
     */
    @MyLog(value = "申请创建社团审核操作")
    public String updateAppAssAudInfo(Association association) {
        return communal.RUD(auditMapper.updateAppAssAudInfo(association));
    }

    /**
     * 查询活动申请审核
     *
     * @return 活动申请审核
     */
    public String queryActAud(int page,int limit) {
        log.debug("执行AuditServiceImpl的queryActAud");
        return communal.runterListJson(page,limit,auditMapper.queryActAud());
    }

    /**
     * 审核操作
     *
     * @param activity 审核信息
     * @return 操作成功或失败的信息
     */
    @MyLog(value = "申请创建活动审核操作")
    public String updateActAud(Activity activity) {
        return communal.RUD(auditMapper.updateActAud(activity));
    }

    /**
     * 查询加入社团审核
     *
     * @return 加入社团审核信息
     */
    public String queryAppAssPeo(int page,int limit) {
        log.debug("执行AuditServiceImpl的queryAppAssPeo");
        int a_id = associationAdministrationMapper.queryAssUserId(communal.getUser());
        return communal.runterListJson(page,limit,auditMapper.queryAppAssPeo(a_id));
    }

    /**
     * 审核操作
     *
     * @param user_ass 审核信息
     * @return 操作成功或失败的信息
     */
    @MyLog(value = "申请加入社团审核操作")
    public String updateAppAssPeo(User_ass user_ass) {
        return communal.RUD(auditMapper.updateAppAssPeo(user_ass));
    }
}
